///*
// *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
// *
// *  Redistribution and use in source and binary forms, with or without
// *  modification, are permitted provided that the following conditions are met:
// *
// *  Redistributions of source code must retain the above copyright notice,
// *  this list of conditions and the following disclaimer.
// *  Redistributions in binary form must reproduce the above copyright
// *  notice, this list of conditions and the following disclaimer in the
// *  documentation and/or other materials provided with the distribution.
// *  Neither the name of the dreamlu.net developer nor the names of its
// *  contributors may be used to endorse or promote products derived from
// *  this software without specific prior written permission.
// *  Author: Chill 庄骞 (smallchill@163.com)
// */
//package com.plian.system.service.fr.vehicle.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.plian.Tools.CollectionUtil;
//import com.plian.system.entity.fr.vehicle.VehicleInfo;
//import com.plian.system.entity.fr.vehicle.VehicleScrap;
//import com.plian.system.enumeratea.BillStatus;
//import com.plian.system.enumeratea.CarStatus;
//import com.plian.system.mapper.fr.vehicle.VehicleScrapMapper;
//import com.plian.system.mybatis.base.BaseServiceImpl;
//import com.plian.system.service.fr.vehicle.IVehicleInfoService;
//import com.plian.system.service.fr.vehicle.IVehicleScrapService;
//import lombok.AllArgsConstructor;
//import org.springframework.stereotype.Service;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Optional;
//import java.util.stream.Collectors;
//
///**
// * 原有车辆更新报废处置 服务实现类
// *
// * @author jianglei
// * @since 2019-09-26
// */
//@Service
//@AllArgsConstructor
//public class VehicleScrapServiceImpl extends BaseServiceImpl<VehicleScrapMapper, VehicleScrap> implements IVehicleScrapService {
//
//    private IVehicleInfoService vehicleInfoService;
//
//    @Override
//    public boolean saveOrUpdate(VehicleScrap vehicleScrap) {
//        if (vehicleScrap.getStatus() != null && vehicleScrap.getStatus() != BillStatus.INIT.billStatus() ) {
//            return false;
//        }
//        vehicleScrap.setStatus(BillStatus.INIT.billStatus());
//        return super.saveOrUpdate(vehicleScrap);
//    }
//
//    @Override
//    public boolean deleteLogic(List<Long> ids) {
//		List<Long> vehicleInfoIds = new ArrayList<>();
//		for (Long id : ids) {
//			VehicleScrap vehicleScrap = getById(id);
//			if (vehicleScrap == null) {
//				return false;
//			} else if (vehicleScrap.getStatus() != null && vehicleScrap.getStatus() != BillStatus.INIT.billStatus()) {
//				return false;
//			}
//			vehicleInfoIds.add(vehicleScrap.getVehicleInfoId());
//		}
//		vehicleInfoService.updateStatus(vehicleInfoIds, CarStatus.USING.getStatus());
//		return super.deleteLogic(ids);
//    }
//
//
//	@Override
//	public Boolean deleteLogicByUpdateId(List<Long> ids) {
//		QueryWrapper<VehicleScrap> queryWrapper = new QueryWrapper<>();
//		queryWrapper.in("vehicle_update_id", ids);
//		List<VehicleScrap> vehicleScraps = list(queryWrapper);
//		if (CollectionUtil.isNotEmpty(vehicleScraps)){
//			return deleteLogic(vehicleScraps.stream().map(VehicleScrap::getId).collect(Collectors.toList()));
//		}
//		return true;
//	}
//
//
//	@Override
//	public Boolean checkIsExisted(List<String> oldScrapNumberPlates, String numberPlate) {
//
//		if (Optional.ofNullable(numberPlate).isPresent()) {
//
//			/**
//			 * 车牌在老数据中存在直接返回
//			 */
//			if (CollectionUtil.isNotEmpty(oldScrapNumberPlates) && oldScrapNumberPlates.contains(numberPlate)){
//				return true;
//			}
//
//			QueryWrapper<VehicleInfo> condition = new QueryWrapper<>();
//			condition.eq("number_plate", numberPlate);
//			condition.eq("status",CarStatus.USING.getStatus());
//			VehicleInfo vehicleInfo = vehicleInfoService.getOne(condition);
//
//			/**
//			 * 判断新增车牌状态
//			 */
//			if (!Optional.ofNullable(vehicleInfo).isPresent()){
//				return false;
//			}
//
//		}
//		return true ;
//	}
//}
